package com.rainripple.java.starter.user.web;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.rainripple.java.starter.user.entity.User;
import com.rainripple.java.starter.user.service.AccountService;

@Controller
@RequestMapping(value = "/user")
public class UserController {

	@Autowired
	private AccountService accountService;

	@RequestMapping(value = { "list", "" })
	public String list(Model model) {
		List<User> users = accountService.getAllUser();
		model.addAttribute("users", users);
		return "account/userList";
	}



	@RequestMapping(value = "update/{id}")
	public String updateForm(@PathVariable("id") Long id, Model model) {
		model.addAttribute("user", accountService.get(id));
		return "account/userForm";
	}



}
